<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<%@ page language="java" contentType="text/html; charset=UTF-8"  pageEncoding="UTF-8" import="java.util.List"%>
<html>
<head>
<%@ include file="/jsp/include/header.jsp"%>
<script type="text/javascript" charset="UTF-8">
	var dg1;
	var d1;
	var f1;
	
	var dg2;
	var d2;
	var f2;
	var log_id="";
	$(function() {

		f1 = $('#f1').form();
 
		d1 = $('#d1').show().dialog({
			modal : true,
			title : '更新日志',
			buttons : [ {
				text : '确定',
				handler : function() {
					var data=JSON.stringify(f1.form("serialize"));
					$("input[name=data]").val(data);
					 
					f1.form('submit', {
						url : '<%=ctx%>/demand/upLog/save.htm',
						success : function(v) {
							try {
								d1.dialog('close');
								$.messager.show({
									msg : '创建成功！',
									title : '提示'
								});
								dg1.datagrid('reload');
								 
							} catch (e) {
								$.messager.show({
									msg : '操作失败！',
									title : '提示'
								});
							}
						}
					});
					 
				}
			},{
				text : '取消',
				handler : function() {
					d1.dialog('close');
				}
			}]
		}).dialog('close');

		dg1 = $('#dg1').datagrid({
			url : '<%=ctx%>/demand/upLog/list.htm',
			toolbar : '#toolbar',
			title : '更新日志',
			iconCls : 'icon-save',
			pagination : true,
			pageSize : 5,
			pageList : [5],
			fit : true,
			//fitColumns : true,
			//nowrap : true,
			border : true,
			selectOnCheck:true,
			checkOnSelect:true,
			singleSelect:true,
			idField : 'log_id',
			sortName:'up_num',
			frozenColumns : [ [ {
				field : 'log_id',
				width : 50,
				checkbox : true
			},
			{
				field : 'up_num',
				title : '更新批次号',
				width : 100
			},
			{
				field : 'sys_id_',
				title : '所属系统',
				width : 100
			},
			{
				field : 'version',
				title : '版本号',
				width : 100
			}
			] ],
			columns : [ [
			{
				field : 'up_date',
				title : '更新时间',
				width : 100
			},
			{
				field : 'up_type_',
				title : '更新类型',
				width : 100
			},
			{
				field : 'up_op_',
				title : '更新人员',
				width : 100
			},
			{
				field : 'is_up_',
				title : '是否发布',
				width : 100
			},
			{
				field : 'up_dir',
				title : '更新报告',
				width : 200
			},
			{
				field : 'remark',
				title : '说明',
				width : 200
			}
			] ],
			onClickCell: function(index,field,value){
				var rows = dg1.datagrid('getRows');
				log_id=rows[index].log_id;
				dg2.datagrid('load', {
					log_id : rows[index].log_id
				}).datagrid({
						title:"【"+rows[index].up_num+"】更新详细",
						fit:true
				  });
			}
		});
		
		f2 = $('#f2').form();
		 
		d2 = $('#d2').show().dialog({
			modal : true,
			title : '更新详细',
			buttons : [ {
				text : '确定',
				handler : function() {
					var formData=f2.form("serialize");
					formData.log_id=log_id;
					var data=JSON.stringify(formData);
					$("input[name=data]").val(data);
					
					f2.form('submit', {
						url : '<%=ctx%>/demand/upDetail/save.htm',
						success : function(v) {
							try {
								 
								d2.dialog('close');
								$.messager.show({
									msg : '创建成功！',
									title : '提示'
								});
								dg2.datagrid('reload');
								 
							} catch (e) {
								$.messager.show({
									msg : '操作失败！',
									title : '提示'
								});
							}
						}
					});
					 
				}
			},{
				text : '取消',
				handler : function() {
					d2.dialog('close');
				}
			}]
		}).dialog('close');

		dg2 = $('#dg2').datagrid({
			url : '<%=ctx%>/demand/upDetail/list.htm',
			toolbar : '#toolbar2',
			title : '更新详细',
			iconCls : 'icon-save',
			pagination : true,
			pageSize : 5,
			pageList : [5],
			fit : true,
			//fitColumns : true,
			//nowrap : true,
			border : true,
			idField : 'id',
			sortName:'dt_num',
			frozenColumns : [ [ {
				field : 'id',
				width : 50,
				checkbox : true
			},
			{
				field : 'dt_num',
				title : '更新序列号',
				width : 100
			},
			{
				field : 'contact_num',
				title : '内控号',
				width : 100
			}
			] ],
			columns : [ [ 
			{
				field : 'remark',
				title : '内容概述',
				width : 200
			},
			{
				field : 'code_type_',
				title : '开发类型',
				width : 100
			},
			{
				field : 'state_',
				title : '开发状态',
				width : 100
			},
			{
				field : 'finish_date',
				title : '开发完成时间',
				width : 100
			},
			{
				field : 'doc_path',
				title : '开发文档',
				width : 100
			},
			{
				field : 'coder',
				title : '开发人员',
				width : 100
			},
			{
				field : 'test_path',
				title : '测试报告',
				width : 100
			},
			{
				field : 'test_op_',
				title : '测试人员',
				width : 100
			},
			{
				field : 'test_result_',
				title : '测试结果',
				width : 100
			}
			] ],
			onDblClickCell: function(index,field,value){
				var rows = dg2.datagrid('getRows');
				d2.dialog('open');
				f2.form('clear');
				f2.form('load','<%=ctx%>/demand/upDetail/get.htm?id='+rows[index].id);
				
			}
		});


	});

	function append() {
		d1.dialog('open');
		f1.form('clear');
	}

	function edit() {
		var rows = dg1.datagrid('getSelections');
		if (rows.length != 1 && rows.length != 0) {
			var names = [];
			for ( var i = 0; i < rows.length; i++) {
				names.push(rows[i].name);
			}
			$.messager.show({
				msg : '只能择一个记录编辑！您已经选择了【' + names.join(',') + '】' + rows.length + '条',
				title : '提示'
			});
		} else if (rows.length == 1) {
			d1.dialog('open');
			f1.form('clear');
			f1.form('load','<%=ctx%>/demand/upLog/get.htm?id='+rows[0].log_id);
		}else{
			$.messager.show({
				msg : '请选择一条记录进行操作',
				title : '提示'
			});
		}
	}
	
	function remove() {
		var ids = [];
		var rows = dg1.datagrid('getSelections');
		if (rows.length > 0) {
			$.messager.confirm('请确认', '您要删除当前所选项目？', function(r) {
				if (r) {
					for ( var i = 0; i < rows.length; i++) {
						ids.push(rows[i].log_id);
					}
					$.ajax({
						url : '<%=ctx%>/demand/upLog/del.htm',
						data : {
							id : ids.join(',')
						},
						cache : false,
						success : function(response) {
							dg1.datagrid('unselectAll');
							dg1.datagrid('reload');
							$.messager.show({
								title : '提示',
								msg : '删除成功！'
							});
						}
					});
				}
			});
		} else {
			$.messager.alert('提示', '请选择要删除的记录！', 'error');
		}
	}

	function searchFun() {
		dg1.datagrid('load', {
			createdatetimeStart : $('#toolbar input[comboname=createdatetimeStart]').datetimebox('getValue'),
			createdatetimeEnd : $('#toolbar input[comboname=createdatetimeEnd]').datetimebox('getValue')
		});
	}
	function clearFun() {
		$('#toolbar input').val('');
		dg1.datagrid('load', {});
	}
	
	function append2() {
		if(log_id==""){
			$.messager.show({
				msg : '请先选择一条更新日志再进行操作',
				title : '提示'
			});
		}else{
			d2.dialog('open');
			f2.form('clear');
		}
		
	}

	function edit2() {
		var rows = dg2.datagrid('getSelections');
		if (rows.length != 1 && rows.length != 0) {
			var names = [];
			for ( var i = 0; i < rows.length; i++) {
				names.push(rows[i].name);
			}
			$.messager.show({
				msg : '只能择一个记录编辑！您已经选择了【' + names.join(',') + '】' + rows.length + '条',
				title : '提示'
			});
		} else if (rows.length == 1) {
			d2.dialog('open');
			f2.form('clear');
			f2.form('load','<%=ctx%>/demand/upDetail/get.htm?id='+rows[0].id);
		}else{
			$.messager.show({
				msg : '请选择一条记录进行操作',
				title : '提示'
			});
		}
	}
	
	function remove2() {
		var ids = [];
		var rows = dg2.datagrid('getSelections');
		if (rows.length > 0) {
			$.messager.confirm('请确认', '您要删除当前所选项目？', function(r) {
				if (r) {
					for ( var i = 0; i < rows.length; i++) {
						ids.push(rows[i].id);
					}
					$.ajax({
						url : '<%=ctx%>/demand/upDetail/del.htm',
						data : {
							id : ids.join(',')
						},
						cache : false,
						success : function(response) {
							dg2.datagrid('unselectAll');
							dg2.datagrid('reload');
							$.messager.show({
								title : '提示',
								msg : '删除成功！'
							});
						}
					});
				}
			});
		} else {
			$.messager.alert('提示', '请选择要删除的记录！', 'error');
		}
	}

</script>
</head>
<body class="easyui-layout" >
<div data-options="region:'north',border:false" style="height:260px">
		<div id="toolbar" class="datagrid-toolbar" style="height: auto;">
			<fieldset>
				<legend>筛选</legend>
				<table class="tableForm">
					 
					<tr> <th>关键字</th>
						<td><input name="createdatetimeStart"  class="easyui-datebox" style="width: 150px;" editable="false" />--
						<input name="createdatetimeEnd"  class="easyui-datebox" style="width: 150px;" editable="false" />
							<a class="easyui-linkbutton" iconCls="icon-search" plain="true" onclick="searchFun();" href="javascript:void(0);">查找</a>
							<a class="easyui-linkbutton" iconCls="icon-search" plain="true" onclick="clearFun();" href="javascript:void(0);">清空</a>
						</td>
					</tr>
				 
				</table>
			</fieldset>
			<div>
				<a class="easyui-linkbutton" iconCls="icon-add" onclick="append();" plain="true" href="javascript:void(0);">增加</a>
				<a class="easyui-linkbutton" iconCls="icon-remove" onclick="remove();" plain="true" href="javascript:void(0);">删除</a> 
				<a class="easyui-linkbutton" iconCls="icon-edit" onclick="edit();" plain="true" href="javascript:void(0);">编辑</a>
				<a class="easyui-linkbutton" iconCls="icon-undo" onclick="dg1.datagrid('unselectAll');" plain="true" href="javascript:void(0);">取消选中</a>
			</div>
		</div>
		<table id="dg1"></table>
</div>
<div data-options="region:'center'" style="height:280px">
	<div id="toolbar2" class="datagrid-toolbar" style="height: auto;">
			<div>
				<a class="easyui-linkbutton" iconCls="icon-add" onclick="append2();" plain="true" href="javascript:void(0);">增加</a>
				<a class="easyui-linkbutton" iconCls="icon-remove" onclick="remove2();" plain="true" href="javascript:void(0);">删除</a> 
				<a class="easyui-linkbutton" iconCls="icon-edit" onclick="edit2();" plain="true" href="javascript:void(0);">编辑</a>
				<a class="easyui-linkbutton" iconCls="icon-undo" onclick="dg2.datagrid('unselectAll');" plain="true" href="javascript:void(0);">取消选中</a>
			</div>
		</div>
		<table id="dg2"></table>
</div> 
 

    <div id="d1" style="display: none;overflow: hidden;">
		<form id="f1" method="post">
		 <input name="log_id" type="hidden" />
		 <input name="data" type="hidden" />
		 <table class="tableForm">
		     <tr>
			   <td style="width:70px;" >更新批次号：</td>
			    <td style="width:150px;">    
				<input name="up_num"  readonly="readonly" style="background-color:khaki"  />
			    </td>
			   <td style="width:70px;" >所属系统：</td>
			    <td style="width:150px;">    
				 <select name="sys_id"  style="width: 150px;" class="easyui-combobox"  
                    			 data-options="editable:false,
											   required:true,
                    			 			   valueField:'code',
                    			 			   textField:'code_desc',
                    			 			   url:'<%=ctx%>/sys/paramGroup/getParam.htm?info=OS4cqbVroP&info=d_contact&info=sys_id'">
                </select>
			    </td>
		     </tr>
		     <tr>
	 
			   <td style="width:70px;" >版本号：</td>
			    <td style="width:150px;">    
				<input name="version" class="easyui-validatebox" data-options="required:true,validType:'maxLength[10]'" />
			    </td>
	 
			   <td style="width:70px;" >更新时间：</td>
			    <td style="width:150px;">    
				<input name="up_date"  class="easyui-datebox" style="width: 150px;" editable="false"   required="true"/>
			    </td>
		     </tr>
		     <tr>
	 
			   <td style="width:70px;" >更新类型：</td>
			    <td style="width:150px;">
				 <select name="up_type"  style="width: 150px;" class="easyui-combobox"  
                    			 data-options="editable:false,
											   required:true,
                    			 			   valueField:'code',
                    			 			   textField:'code_desc',
                    			 			   url:'<%=ctx%>/sys/paramGroup/getParam.htm?info=OS4cqbVroP&info=d_up_log&info=up_type'">
                </select>
			    </td>
	 
			   <td style="width:70px;" >更新人员：</td>
			    <td style="width:150px;">
				<select name="up_op"  style="width: 160px;" class="easyui-combogrid"  
                    			 data-options="idField:'ur_id',
												textField:'user_name',
												required:true,
												editable:false,
												url:'<%=ctx%>/sys/paramGroup/getParamGrid.htm?info=UGxosPAiph',
												columns:[[
													{field:'ur_id',title:'ID',width:60,hidden : true},
													{field:'user_name',title:'名称',width:80},
													{field:'role_name',title:'角色',width:50}
													
												]]">
               </select>
			    </td>
		     </tr>
		     <tr>
	 
			   <td style="width:70px;" >是否发布：</td>
			    <td style="width:150px;" colspan="3">    
				<select name="is_up"  style="width: 150px;" class="easyui-combobox"  
                    			 data-options="editable:false,
											   required:true,
                    			 			   valueField:'code',
                    			 			   textField:'code_desc',
                    			 			   url:'<%=ctx%>/sys/paramGroup/getParam.htm?info=OS4cqbVroP&info=comm&info=yes_no'">
                </select>
			    </td>
			 </tr>
			 <tr>
			   <td style="width:70px;" >更新报告：</td>
			    <td style="width:150px;" colspan="3">    
				<textarea name="up_dir"  class="easyui-validatebox" cols="30" rows="3" data-options="required:true,validType:'maxLength[200]'"  >
					</textarea>
			    </td>
		     </tr>
		     <tr>
	 
			   <td style="width:70px;" >说明：</td>
			    <td style="width:150px;" colspan="3">    
					<textarea name="remark" class="easyui-validatebox" cols="30" rows="4" data-options="validType:'maxLength[200]'"  >
					</textarea>
			    </td>
      </table>
  </form>
 </div>  
 
    <div id="d2" style="display: none;overflow: hidden;">
		<form id="f2" method="post">
		 <input name="id" type="hidden" />
		 <input name="log_id" type="hidden" />
		 <input name="data" type="hidden" />
		 <table class="tableForm">
		     <tr>
			   <td style="width:70px;" >更新序号：</td>
			    <td style="width:150px;" colspan="3">    
				<input name="dt_num" readonly="readonly" style="background-color:khaki" />
			    </td>
			   
		     </tr>
		     <tr>
			    <td style="width:70px;" >内部管控编号：</td>
			    <td style="width:150px;" colspan="3" >
				<select name="contact_num"  style="width: 340px;" class="easyui-combogrid"  
                    			 data-options="idField:'contact_num',
												textField:'contact_title',
												required:true,
												editable:false,
												url:'<%=ctx%>/sys/paramGroup/getParamGrid.htm?info=BkSiD8bJUN',
												columns:[[
													{field:'contact_num',title:'内控号',width:100},
													{field:'contact_title',title:'名称',width:220}
												]]">
               </select>
			    </td>
		     </tr>
		     <tr>
			   <td style="width:70px;" >更新内容概述：</td>
			    <td style="width:150px;" colspan="3">    
				<textarea name="remark" class="easyui-validatebox" cols="30" rows="4" 
				data-options="validType:'maxLength[200]'"  ></textarea>
			    </td>
		     </tr>
		     <tr>
			   <td style="width:70px;" >开发类型：</td>
			    <td style="width:150px;">    
				<select name="code_type"  style="width: 150px;" class="easyui-combobox"  
                    			 data-options="editable:false,
											   required:true,
                    			 			   valueField:'code',
                    			 			   textField:'code_desc',
                    			 			   url:'<%=ctx%>/sys/paramGroup/getParam.htm?info=OS4cqbVroP&info=d_up_detail&info=code_type'">
                </select>
			    </td>
	 
			   <td style="width:70px;" >开发状态：</td>
			    <td style="width:150px;"> 
				<select name="state"  style="width: 150px;" class="easyui-combobox"  
                    			 data-options="editable:false,
											   required:true,
                    			 			   valueField:'code',
                    			 			   textField:'code_desc',
                    			 			   url:'<%=ctx%>/sys/paramGroup/getParam.htm?info=OS4cqbVroP&info=d_up_detail&info=state'">
                </select>
			    </td>
		     </tr>
		     <tr>
	 
			   <td style="width:70px;" >开发完成时间：</td>
			    <td style="width:150px;">    
				<input name="finish_date"  class="easyui-datebox" style="width: 150px;" editable="false"   required="true" />
			    </td>
	 			 <td style="width:70px;" >开发人员：</td>
			    <td style="width:150px;">    
				<select name="coder"  style="width: 150px;" class="easyui-combobox"  
                    			 data-options="required:true,
                    			 			   valueField:'user_name',
                    			 			   textField:'user_name',
                    			 			   multiple:true,
                    			 			   url:'<%=ctx%>/sys/paramGroup/getParam.htm?info=1zwPLKBSw2'">
                </select>
			    </td>
		     </tr>
		     <tr>
			     <td style="width:70px;" >开发文档：</td>
			    <td style="width:150px;" colspan="3">
				<textarea name="doc_path" class="easyui-validatebox" cols="30" rows="4" 
				data-options="validType:'maxLength[200]'"  ></textarea>
			    </td>
	 		</TR>
	 		<tr>
			   <td style="width:70px;" >测试报告：</td>
			    <td style="width:150px;"  colspan="3">
				<textarea name="test_path" class="easyui-validatebox" cols="30" rows="4" 
				data-options="validType:'maxLength[200]'"  ></textarea>
			    </td>
		     </tr>
		     <tr>
	 
			   <td style="width:70px;" >测试人员：</td>
			    <td style="width:150px;">
				<select name="test_op"  style="width: 160px;" class="easyui-combogrid"  
                    			 data-options="idField:'ur_id',
												textField:'user_name',
												editable:false,
												url:'<%=ctx%>/sys/paramGroup/getParamGrid.htm?info=UGxosPAiph',
												columns:[[
													{field:'ur_id',title:'ID',width:60,hidden : true},
													{field:'user_name',title:'名称',width:80},
													{field:'role_name',title:'角色',width:50}
													
												]]">
               </select>
			    </td>
			   <td style="width:70px;" >测试结果：</td>
			    <td style="width:150px;">
				<select name="test_result"  style="width: 150px;" class="easyui-combobox"  
                    			 data-options="editable:false,
                    			 			   valueField:'code',
                    			 			   textField:'code_desc',
                    			 			   url:'<%=ctx%>/sys/paramGroup/getParam.htm?info=OS4cqbVroP&info=d_up_detail&info=test_result'">
                </select>
			    </td>
		     </tr>
      </table>
  </form>
 </div>  
 
 
</body>
</html>